/** 电商管理 接口
 * import { GetProductList } from '@/api/onlineMan'
 */

import {
  httpRequest
} from './index'

// 商品列表
export const GetProductList = (params, type) => {
  // 上架中 product/list?publishStatus=1
  if (type === '1') {
    let param = params || {}
    param.publishStatus = '1'
    return httpRequest('product/list', params, 'GET')
  }
  // 仓库中 product/list?publishStatus=0
  if (type === '2') {
    let param = params || {}
    param.publishStatus = '0'
    return httpRequest('product/list', params, 'GET')
  }
  // 已售罄 product/nosku/list
  if (type === '3') {
    return httpRequest('product/nosku/list', params, 'GET')
  }
  // 全部 product/list?publishStatus=
  if (type === '4') {
    let param = params || {}
    param.publishStatus = ''
    return httpRequest('product/list', params, 'GET')
  }
}

// 快捷修改商品
export const EditQuickProduct = (params) => httpRequest('product/quick/update', params)

// 上下架
export const ProductUpLowFrames = (params) => httpRequest('product/update/publishStatus', params)

// 删除
export const ProductRemove = (params) => httpRequest('product/update/deleteStatus', params)

// 商品评价统计
// GET / comment / Praise
export const ProductEvaluateTotal = (params) => httpRequest('comment/Praise', params, 'GET')

// 商品评价列表
export const ProductEvaluateList = (params) => httpRequest('comment/list', params, 'GET')

// 商品评价回复
export const ProductCommentReplay = (params) => httpRequest('comment/replay', params)

// 商品评价隐藏显示
export const ProductCommentHide = (params) => httpRequest('comment/hide', params)

// 商品评价删除
export const ProductCommentRemove = (params) => httpRequest('comment/remove', params)

// 添加商品
export const AddProduct = (params) => httpRequest('product/create', params)

// 获取修改商品具体信息
export const GetProductInfo = (params) => httpRequest('product/getInfo/' + params, {}, 'GET')

// 修改商品
export const EditProduct = (params) => httpRequest('product/update', params)

// 获取商品编码
// type(integer, optional): 类型： 1： 商品编码 2： Sku编码
// count(integer, optional): 生成个数,
export const GetProductSn = (params) => httpRequest('product/generate/code', params)

// 商品列表

// 商品分类
export const GetProductClassifyList = (params) => httpRequest('productCategory/list/withChildren', params, 'GET')
export const AddProductClassify = (params) => httpRequest('productCategory/create', params)
export const UpdateProductClassify = (params) => httpRequest('productCategory/update', params)
export const ProductCategoryShowStatus = (params) => httpRequest('productCategory/update/showStatus', params)
export const RemoveProductCategory = (params) => httpRequest('productCategory/delete', params)
// 商品分类

// 商品分组
export const GetProductGroupingList = (params) => httpRequest('product/group/list', params, 'GET')
export const AddProductGroup = (params) => httpRequest('product/group/product/create', params)
export const RemoveProductGroup = (params) => httpRequest('product/group/product/ddd', params)
export const EditProductGroup = (params) => httpRequest('admin/option/update', params)
/* 分组下的商品 */
export const GetProductGroupingGoodsList = (params) => httpRequest('product/group/product/list', params, 'GET')
export const DeleteProductGroupingGoods = (params) => httpRequest('product/group/product/delete', params)
export const ProductSortEdit = (params) => httpRequest('product/group/product/sort', params)
export const ProductGroupEnable = (params) => httpRequest('product/group/product/state', params)
// 商品分组

// 服务承诺
export const GetServicePromiseList = (params) => httpRequest('admin/option/list', params, 'GET')
export const AddServicePromise = (params) => httpRequest('admin/option/create', params)
export const EditServicePromise = (params) => httpRequest('admin/option/update', params)
export const RemoveServicePromise = (params) => httpRequest('admin/option/delete', params)
// 服务承诺

// 退货地址
export const GetReturnAddressList = (params) => httpRequest('companyAddress/list', params, 'GET')
export const AddReturnAddress = (params) => httpRequest('companyAddress/create', params)
export const EditReturnAddress = (params) => httpRequest('companyAddress/update', params)
export const SetDetultReceiveAddress = (params) => httpRequest('companyAddress/updatestate', params)
export const SetDetultSendAddress = (params) => httpRequest('companyAddress/updateSendState', params)
export const RemoveAddress = (params) => httpRequest('companyAddress/delete/batch', params)
// 退货地址

/* 品牌 */
export const GetBrandList = (params) => httpRequest('brand/list', params, 'GET')
export const GetBrandListAll = (params) => httpRequest('brand/listAll', params, 'GET')

export const EditBrandShowStatus = (params) => httpRequest('brand/update/showStatus', params)
export const EditBrandFactoryStatus = (params) => httpRequest('brand/update/factoryStatus', params)

export const AddBrand = (params) => httpRequest('brand/create', params)
export const UpdateBrand = (params) => httpRequest('brand/update', params)
export const RemoveBrand = (params) => httpRequest('brand/delete/batch', params)

/* 运费配置 */
export const GetFreightModelList = (params) => httpRequest('freight/list', params, 'GET')
export const GetFreightModelAllList = (params) => httpRequest('freight/list', params, 'GET')
export const AddFreightModel = (params) => httpRequest('freight/create', params)
export const UpdateFreightModel = (params) => httpRequest('freight/update', params)
export const DeleteFreightModel = (params) => httpRequest('freight/delete', params)
export const GetFreightModelDetail = (params) => httpRequest('freight/info/' + params, {}, 'GET')

export const GetCommonRegions = (params) => httpRequest('freight/commonRegions', params, 'GET')

/* 轮播图配置 */
export const AddBanner = (params) => httpRequest('banner/addBanner', params)
export const GetBannerList = (params) => httpRequest('banner/listInPage', params, 'GET')
export const UpdataBanner = (params) => httpRequest('banner/updataBanner', params)

/* 热词配置 */
export const GetHotWordList = (params) => httpRequest('productSearch/hot/keywords', params, 'GET')
export const AddHotWord = (params) => httpRequest('productSearch/hot/addKeywords', params)
export const UpdateHotWord = (params) => httpRequest('productSearch/hot/updateKeywords', params)
export const DeleteHotWordProduct = (params) => httpRequest('productSearch/hot/keywords/deleteProduct', params)
export const GetHotWordDetail = (params) => httpRequest('productSearch/hot/keywords/detail', params, 'GET')
export const HotWordAppendProduct = (params) => httpRequest('productSearch/hot/addKeywords', params)

/* 营销管理 */
export const CreateMarket = (params) => httpRequest('market/create', params)
export const UpdateMarket = (params) => httpRequest('market/update', params)
export const DelMarket = (params) => httpRequest('market/delete/' + params.id, params)
export const DelAllMarket = (params) => httpRequest('market/delete', params)
export const DelMarketAllProduct = (params) => httpRequest('market/delete/item/products', params)
/* 各类型下的列表数据 */
export const GetMarketList = (params) => httpRequest('market/list', params, 'GET')
export const GetMarketDetail = (params) => httpRequest('market/get/' + params, {}, 'GET')

/* 商品选择库 */
// export const ProductPool = (params) => httpRequest('product/select', params, 'GET')
export const ProductPool = (params) => httpRequest('product/selectProduct', params, 'GET')

/* 优选推荐 */
export const GetOptiRecommendProduct = (params) => httpRequest('productSearch/recommend/products', params, 'GET')
export const AddOptiRecommendProduct = (params) => httpRequest('productSearch/recommend/addProduct', params)
export const UpdateOptiRecommendProduct = (params) => httpRequest('productSearch/recommend/update', params)
export const DeleteOptiRecommendProduct = (params) => httpRequest('productSearch/recommend/delete', params, 'POST')

/* 分类导航 */
export const GetClassActivityNavList = (params) => httpRequest('market/navigation/list', params, 'GET')
export const UpdateClassActivityNav = (params) => httpRequest('market/update/navigation', params)
export const AddClassActivityNav = (params) => httpRequest('market/add/navigation', params)
export const DeleteClassActivityNav = (params) => httpRequest('market/add/navigation', params)
